package com.qinggeng.common.exception;

import com.qinggeng.common.constant.HttpStatus;
import com.qinggeng.common.enums.ShowTypeEnum;

/**
 * 自定义异常
 * 
 * @author qinggeng
 */
public class CustomException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    private final Integer code;

    private final Integer type;

    private final String message;

    private String content;

    public CustomException(String message) {
        this(HttpStatus.ERROR,message);
    }
    public CustomException(String message,int type )    {
        this(HttpStatus.ERROR,message,type);
    }

    public CustomException(Integer code,String message)    {
        this(code,message,ShowTypeEnum.后台.getValue());
    }
    public CustomException(Integer code,String message,Integer type)    {
        this.code = code;
        this.message = message;
        this.type=type;
        if(ShowTypeEnum.用户.getValue()==type){
            this.content=message;
        }
    }

    @Override
    public String getMessage()    {
        return message;
    }

    public Integer getCode()    {
        return code;
    }

    public Integer getType() {
        return type;
    }

    public String getContent() {
        return content;
    }
}
